fix: make PromptVersion.published_at optional#2
Open
anxkhn wants to merge 1 commit into
Open
Conversation
anxkhn
force-pushed
the
fix/prompt-version-published-at-nullable
branch
from
July 1, 2026 14:21
2b0422e to
18ed180
Compare
published_at is only populated once a version is set to live; the API returns null for draft, stable and archived versions (as the field description itself states). It was generated as a required, non-nullable datetime, so PromptVersion.from_dict raised pydantic ValidationError for any non-live version. This broke create_version (returns a draft), promote_version (draft -> stable, never-live), duplicate_version, get_version and, because one element poisons the whole array, list_versions. Make the field Optional[datetime] with a None default, mirroring the already-correct APIKey.last_used_at which shares the same 'Null if ...' semantics. Add regression tests covering null, omitted and populated published_at plus a list_versions payload containing a draft.
anxkhn
force-pushed
the
fix/prompt-version-published-at-nullable
branch
from
July 1, 2026 14:29
18ed180 to
46dfaf5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
px0-python is generated from the OpenAPI spec in px0-ai/px0, so this is ultimately a spec issue: the durable fix belongs in that spec, and this patch corrects the currently published SDK to match. Happy to redo it as a spec-side change if you prefer.
published_atis populated only once a version is set tolive. For draft, stable and archived versions the API returnspublished_at: null, but the field was generated as a required, non-nullabledatetime, sofrom_dictraisedValidationErrorand the SDK could not read the response.The underlying fix belongs in the OpenAPI document: mark
published_atnullable: trueand remove it fromrequiredon thePromptVersionschema. This applies the equivalent change to the generated model so it matches what the generator would produce, mirroringAPIKey.last_used_at, which already handles the same "Null if ..." case:from_dictalready reads the value withobj.get("published_at"), andto_dictusesexclude_none=True, so a null or omitted value round-trips cleanly and is dropped on serialization.docs/PromptVersion.mdis updated to mark the field optional.Why it matters
Without this,
create_version,promote_version,duplicate_version,get_version,archive_versionandlist_versionsall fail whenever the version they touch is notlive(a single non-live element also breaks the wholelist_versionsarray).Testing
Added
tests/test_prompt_version_published_at.pycovering a draft version withpublished_at: null,published_atomitted entirely, a live version keeping its timestamp,to_dictdropping the null field, and alist_versionspayload containing a draft element.pytest test testspasses.Closes #1